package JSP;

import PoJo.Students;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SearchStudentServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


//        获取请求参数
        System.out.println("hello");
        String name = req.getParameter("username");
        System.out.println(name);
        //发送sql语句查询
        List<Students> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(new Students(i+1,"stu"+(i+1),null,null));
        }
        req.setAttribute("stuList",list);
        req.getRequestDispatcher("/search.jsp").forward(req,resp);
    }
    String sql= " SELECT `username` FROM books WHERE `username` LIKE '陈%' ";
}

